<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends Action {
    public function index(){
	//专题研究
		$c=M('zhuanti');	
		$list = $c->order('urid desc')->select();
		$this->assign('list',$list);
	//业务类型
		$ywname	= M('class');
		$data =$ywname->where('clevel = 30')->select();
		$this->assign('data',$data);
	//经典案例
		$case = M('content');
		$listcase = $case->where("id != 'null'")->select();
		$this->assign('content',$listcase);
		foreach($listcase as $item)
		$coidList[] = $item['coid'];
		$m = M('textpic');
		$map['coid'] = array('in', $coidList);
		$pic = $m->where($map)->select();
		foreach ($pic as $item)
		$newpic[$item['coid']] = $item['tename'];
		$this->assign("pic",$newpic);
     //首页内容查询
		$c=M('content');
		$m = M('textpic');
		//单位新闻
		$dw['clid']=3;
		$dwxw= $c->where($dw)->order('coid desc')->limit(3)->select();
		foreach($dwxw as $item)
				 $coidList[] = $item['coid'];
				 $map['coid'] = array('in', $coidList);
				 $pic = $m->where($map)->select();
				 foreach ($pic as $item)
				 $newpicdw[$item['coid']] = $item['tename'];
				 $this->assign("picdw",$newpicdw);
		//行业资讯
		$hy['clid']=4;
		$hyzx= $c->where($hy)->order('coid desc')->limit(5)->select();
		foreach($hyzx as $item)
				 $coidList[] = $item['coid'];
				 $map['coid'] = array('in', $coidList);
				 $pic = $m->where($map)->select();
				 foreach ($pic as $item)
				 $newpichy[$item['coid']] = $item['tename'];
				 $this->assign("pichy",$newpichy);
		//热点聚焦
		$rd['clid']=6;
		$rdjj= $c->where($rd)->order('coid desc')->limit(3)->select();
		foreach($rdjj as $item)
				 $coidList[] = $item['coid'];
				 $map['coid'] = array('in', $coidList);
				 $pic = $m->where($map)->select();
				 foreach ($pic as $item)
				 $newpicrd[$item['coid']] = $item['tename'];
				 $this->assign("picrd",$newpicrd);
		//国际合作
		$gj['clid']=8;
		$gjhz= $c->where($gj)->order('coid desc')->limit(3)->select();
		foreach($gjhz as $item)
				 $coidList[] = $item['coid'];
				 $map['coid'] = array('in', $coidList);
				 $pic = $m->where($map)->select();
				 foreach ($pic as $item)
				 $newpicgj[$item['coid']] = $item['tename'];
				 $this->assign("picgj",$newpicgj);
		//政策法规
		$zc['clid']=7;
		$zcfg= $c->where($zc)->order('coid desc')->limit(5)->select();
		foreach($zcfg as $item)
				 $coidList[] = $item['coid'];
				 $map['coid'] = array('in', $coidList);
				 $pic = $m->where($map)->select();
				 foreach ($pic as $item)
				 $newpiczc[$item['coid']] = $item['tename'];
				 $this->assign("piczc",$newpiczc);
		
        $this->assign('dwxw',$dwxw)->assign('hyzx',$hyzx)->assign('rdjj',$rdjj)->assign('gjhz',$gjhz)->assign('zcfg',$zcfg);



	//导航栏
		$nav = new PublicAction();
		$nav->base();
		//相关阅读
		$nav->reading();
	//首页
		$this->display();
	}
	
	public function zhuanti_list(){
	//专题研究
		$c=M('zhuanti');
		$list = $c->order('urid desc')->select();
		foreach($list as $list){
			$coids = $list['urls'];
			if(preg_match("/(htm)/is",$coids)){
				$begin=strrchr($coids,'-');
				$length=strpos($begin,'_');
				$coid=substr($begin,1,$length-1);
				
			}
			else{
				$begin=strstr($coids,'=');
				$length=strpos($begin,'&');
				$coid=substr($begin,1,$length-1);
			}
			$m=M('content');
			$content = $m->where('coid='.$coid)->select();
			$codate = $content[0]['codate'];
			$codate = substr($codate,0,7);
			$list['codate']=$codate;
			$lists[]=$list;
			
		}
		$this->assign('lists',$lists);
	//分页
		import('ORG.Util.Page');
		$count = $c->count();
		$Page  = new Page($count,30);
		$Page->setConfig('theme','  <span class="li_fist">%upPage%</span> %linkPage% <span class="li_last">%downPage%</span> ');
		$Page->setConfig('prev','<');
		$Page->setConfig('next','>');
		$show = $Page->show();
		$list = $c->order('urid desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('list',$list);
		$this->assign('page',$show);
		//导航栏
		$nav = new PublicAction();
		$nav->base();
		//相关阅读
		$nav->reading();
	//专题研究列表页
		$this->display();
	}
	public function yewulx_list(){
	//业务类型列表页
		$content = M('content');
		$id= $_GET['id'];
		$data = $content->where("clid = $id")->select();
		$map['clid'] = $data[0]['clid'];
		$t=M('class');
		$term = $t->where($map)->select();
		$this->assign('data',$data)->assign('term',$term);
		//导航栏
		$nav = new PublicAction();
		$nav->base();
		//相关阅读
		$nav->reading();
		$this->display();
	}
	
	
}